package com.weifangfirecontrolformal.weifangfirecontrolformal.support.mybatisplus;

import cn.hutool.core.util.StrUtil;

/**
 * 对象操作类
 *
 * @author
 * @date 2018/12/28 11:40
 */
public class QueryWrapper<R> extends com.baomidou.mybatisplus.core.conditions.query.QueryWrapper<R> {


    @Override
    public QueryWrapper<R> eq(String column, Object val) {
        this.eq(val != null && StrUtil.isNotBlank(val.toString()), column, val);
        return this;
    }

    @Override
    public QueryWrapper<R> ne(String column, Object val) {
        this.ne(val != null && StrUtil.isNotBlank(val.toString()), column, val);
        return this;
    }

    public QueryWrapper<R> likes(Object val, String... clounm) {
        likeOr(false, val, clounm);
        return this;
    }

    public QueryWrapper<R> likeOr(boolean isOr, Object val, String... clounm) {
        if (isOr) {
            for (int i = 0; i < clounm.length; i++) {
                this.like(clounm[i],val);
                if (i != clounm.length - 1) {
                    this.or();
                }
            }
        } else {
            for (int i = 0; i < clounm.length; i++) {
                this.like(clounm[i], val);
            }
        }
        return this;
    }
}